#include "Student.h"

Student::Student() {
    studentid = -1;
}
Student::Student(const string &id, const string &name) {
    setStudentId(id);
    setStudentName(name);
}

void Student::setStudentId(const string &id) {
    studentid = id;
}

void Student::setStudentName(const string &name) {
    studentname = name;
}

void Student::setScores(const vector<Score> scores) {
    this->scores = scores;
}

string Student::getStudentId() const {
    return studentid;
}

string Student::getStudentName() const {
    return studentname;
}
void Student::addCourse(Course course) {
    courses.push_back(course);
}

void Student::addScore(Score score) {
    scores.push_back(score);
}
vector<Score> Student::getScores() const {
    return scores;
}

vector<Course> Student::getCourses() const {
    return courses;
}

ostream &operator<<(ostream &output, const Student &stu) {
    output << "Student ID:" << stu.getStudentId() << endl;
    output << "Student Name:" << stu.getStudentName() << endl;
    output << "Courses and Scores:" << endl;
    vector<Score> scores = stu.getScores();
    for (Score score : scores) {
        output << "Course: " << score.getCourseName() << ", Score: " << score.getScore() << endl;
    }
    output << endl;

    return output;
}

istream &operator>>(istream &input, Student &stu) {
    input >> stu.studentid;
    input >> stu.studentname;

    int numofcourses;
    input >> numofcourses;

    for (int i = 0; i < numofcourses; i++) {
        Course course;
        input >> course;
        stu.courses.push_back(course);
        Score score;
        input >> score;
        stu.scores.push_back(score);
    }

    return input;
}